home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / batch / tsbat36.zip / SAFEDEL.BAT < prev    next >
DOS Batch File  |  1992-04-13  |  2KB  |  77 lines

  1. echo off
  2. rem This is a subroutine which safedel.bat calls by calling itself
  3. rem Thus a second batch file is not needed
  4. rem The subroutine deletes a sigle file
  5. if not "%2"=="recurse" goto _begin
  6. :_loop1
  7. set _reply=
  8. ask Delete %1 (y or n)? /d /u
  9. if errorlevel==89 if not errorlevel==90 set _reply=yes
  10. if errorlevel==78 if not errorlevel==79 set _reply=no
  11. if "%_reply%"=="" echo 
  12. if "%_reply%"=="" goto _loop1
  13. if "%_reply%"=="yes" del %1
  14. set reply=
  15. goto _out
  16.  
  17. rem The "actual" safedel.bat starts here
  18. :_begin
  19. echo.
  20. echo ┌───────────────────────────────────────────────────┐
  21. echo │ Safe delete of files                              │
  22. echo │ By Prof. Timo Salmi, ts@chyde.uwasa.fi, 13-Apr-92 │
  23. echo └───────────────────────────────────────────────────┘
  24. echo.
  25.  
  26. if "%1"=="" goto _help
  27.  
  28. rem Check that safedel.bat is available at path or current directory
  29. set _found=no
  30. if exist safedel.bat set _found=yes
  31. for %%d in (%path%) do if exist %%d\safedel.bat set _found=yes
  32. if "%_found%"=="no" goto _err1
  33.  
  34. rem Check that ask.exe is available at path or current directory
  35. set _found=no
  36. if exist ask.exe set _found=yes
  37. for %%d in (%path%) do if exist %%d\ask.exe set _found=yes
  38. if "%_found%"=="no" goto _err2
  39.  
  40. rem Handle the files
  41. :_loop
  42. if not exist %1 goto _err3
  43. rem for MsDos earlier than 3.3 move the rem below one command downwards
  44. rem for %%f in (%1) do %comspec% /e:1024 /c safedel1 %%f
  45. for %%f in (%1) do call safedel %%f recurse
  46. shift
  47. if not "%1"=="" goto _loop
  48. goto _out
  49.  
  50. :_err1
  51. echo You must have safedel.bat at your path (or the current directory)
  52. goto _out
  53.  
  54. :_err2
  55. echo You must have ask.exe at your path (or the current directory)
  56. goto _out
  57.  
  58. :_err3
  59. echo File(s) %1 not found
  60. goto _out
  61.  
  62. :_help
  63. echo Usage: SAFEDEL [FileName1] [FileName2] [FileName3] ...
  64. echo.
  65. echo Wildcards are allowed in the file names.
  66. echo.
  67. echo If you get an "Out of environment space" message, increase your
  68. echo environment space by using shell configuration in config.sys:
  69. echo MsDos 3.30 example: shell=c:\bin\command.com /e:1024 /p
  70. echo.
  71. echo To use this batch you need ask.exe and safedel1.bat either at
  72. echo your path or the current directory.
  73. echo.
  74.  
  75. set _found=
  76. :_out
  77.